<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义回复管理</title>
    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/Theme1/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/animate.min.css" rel="stylesheet">
    <link href="__PUBLIC__/Theme1/css/style.min.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>自定义回复管理<small></small></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal J_ajaxForm" enctype="multipart/form-data" id="myform" action="{:U('Admin/Weixin/addMessage')}" method="post">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">类型:</label>
                            <div class="col-sm-4">
                                <select class="chosen-select form-control" size="1" name="type" id="type" required >
                                    <option value="0">图文</option>
                                    <option value="1">文本</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-4">
                                <input type="text" name="title"class="form-control" value="{$message.title}" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">描述:</label>
                            <div class="col-sm-4">
                                <textarea name="description" rows="8" cols="32"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">图片:</label>

                            <strong>点击图片删除</strong>
                            <div id="preview" onclick="uploadpic()"></div>
                            <if condition="($message.savepath neq '' OR ($message.picurl neq ''))">
                                <div id='wxpic' onclick="uploadpic()">
                                    <img class="re" style="padding: 0px 0px 6px 0px;max-width:200px;max-height:200px;" src="__PUBLIC__{$message.savepath}{$message.picurl}"/>
                                </div>
                                <else/>
                                <img class="re" style="padding: 0px 0px 6px 0px;max-width:200px;max-height:200px;" id="pic_url" src=""/>
                            </if>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"></label>
                            <div class="col-sm-5">
                                <span class="btn btn-primary">上传</span>
                                <input type="file" style="width: 55px;position: relative;left: 0;z-index: 15;height: 35px;top: -30px;opacity: 0;float: none;" name="picurl" value="" id="picurl" onchange="previewImage(this)">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">URL:</label>
                            <div class="col-sm-4">
                                <input type="text" name="url" class="form-control" value="{$message.url}" required>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">关键词:</label>
                            <div class="col-sm-4">
                                <input type="text" name="key" class="form-control" value="{$message.key}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <a class="btn btn-white" href="{:U('Admin/Weixin/reply_list')}">返回</a>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__PUBLIC__/Theme1/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/Theme1/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/Theme1/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/Theme1/js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});
    function uploadpic(){
        $("#wxpic").next("input").remove();
        $("#wxpic").remove();
        $(".re").attr("src","");
        $(".re").attr("style","display:none");
    };

    function previewImage(file) {
        var prevDiv = document.getElementById('preview');
        if (file.files && file.files[0]) {
            var reader = new FileReader();
            reader.onload = function(evt) {
                prevDiv.innerHTML = '<img style="width: 200px;height: 200px" class="re" src="' + evt.target.result + '" />';
                $("#wxpic").next("input").remove();
                $("#wxpic").remove();
            }
            reader.readAsDataURL(file.files[0]);
        } else {
            prevDiv.innerHTML = '<div class="re" style="width: 200px;height: 200px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
            $("#wxpic").next("input").remove();
            $("#wxpic").remove();
        }
    }
</script>
</body>

</html>
